export default {
    state: {
        isCollapse: false,   //控制左侧菜单展开收起
        tabList: [   //面包屑内容
            {
                path: "/",
                name: "home",
                label: "首页",
                icon: "s-home",
                url: "Home/Home",
            },
        ]   
    },
    mutations: {
        //修改菜单状态的方法
        collapseMenu(state) {
            state.isCollapse = !state.isCollapse
        },
        //修改面包屑数据
        selectMenu(state,val) {
            console.log("val",val)
            //判断添加数据是否为首页
            if(val.name !== 'home' && (state.tabList.findIndex(item => item.name === val.name) === -1)) {
                // // 如果当前数据存在返回当前数据的索引，如果不存在返回 -1
                // const index = state.tabList.findIndex(item => item.name === val.name)
                // if(index === -1) {
                //     state.tabList.push(val)
                // }
                state.tabList.push(val)
                
            }

        },
        // 删除指定面包屑
        closeTag(state,item) {
           const index = state.tabList.findIndex(val => val.name === item.name)
            state.tabList.splice(index,1)
        }
    }
}